package domain.itf;

import java.util.List;
import java.util.Set;

import util.DAOException;
import util.VersionException;
import domain.Contact;
import domain.ContactGroup;

public interface IDAOContactGroup {
	
	/**
	 * Return all groups of the database.
	 * @return a {@link List}.
	 * @throws DAOException
	 */
	public List<ContactGroup> getAllGroups() throws DAOException;
	
	/**
	 * Get an {@link ContactGroup} by id.
	 * 
	 * @param id
	 * @return the contact group coresponding with this id.
	 * @throws {@link DAOException}
	 */
	public ContactGroup getById(Integer id) throws DAOException;

	/**
	 * Get an {@link ContactGroup} by id.
	 * 
	 * @param id
	 * @param getContacts if true, get all contacts of the group from database
	 * @return the contact group coresponding with this id.
	 * @throws {@link DAOException}
	 */
	public ContactGroup getById(Integer id, boolean getContacts) throws DAOException;

	/**
	 * Add a new {@link ContactGroup}
	 * 
	 * @param groupName
	 * @param contacts
	 * @return the {@link ContactGroup} created in database.
	 * @throws {@link DAOException}
	 */
	public ContactGroup addContactGroup(String groupName, Set<Contact> contacts)
			throws DAOException;

	/**
	 * A a new {@link ContactGroup}.
	 * @param group
	 * @return
	 * @throws {@link DAOException}
	 */
	public ContactGroup addContactGroup(ContactGroup group) throws DAOException;
	
	
	/**
	 * Update a {@link ContactGroup}.
	 * @param group
	 * @throws {@link DAOException}
	 * @throws {@link VersionException}
	 */
	public ContactGroup updateContactGroup(ContactGroup group) throws DAOException, VersionException;

	/**
	 * Update a {@link ContactGroup}.
	 * 
	 * @param id
	 * @param version
	 * @param groupName
	 * @param contacts
	 * @return the {@link ContactGroup} updated.
	 * @throws {@link DAOException}
	 * @throws {@link VersionException}
	 */
	public ContactGroup updateContactGroup(int id, long version, String groupName,
			Set<Contact> contacts) throws DAOException, VersionException;

	/**
	 * Delete a {@link ContactGroup} from database
	 * 
	 * @param id
	 * @return false if the delete fail, true otherwise.
	 */
	public boolean deleteContactGroup(int id) throws DAOException;

}
